<?php

class AddressRecord extends TActiveRecord
{
	const TABLE = 'addresses';
	
	// fields
	public $id;
	public $country;
	public $city;
	public $postal_code;
	public $street;
	public $number;
	public $description;
	
	public function setId($id)                     { $this->id = $id; }
	public function setCountry($country)           { $this->country = $country; }
	public function setCity($city)                 { $this->city = $city; }
	public function setPostalCode($postal_code)    { $this->postal_code = $postal_code; }
	public function setStreet($street)             { $this->street = $street; }
	public function setNumber($number)             { $this->number = $number; }
	public function setDescription($description)   { $this->description = $description; }

	public function getId()            { return $this->id; }
	public function getCountry()       { return $this->country; }
	public function getCity()          { return $this->city; }
	public function getPostalCode()    { return $this->postal_code; }
	public function getStreet()        { return $this->street; }
	public function getNumber()        { return $this->number; }
	public function getDescription()   { return $this->description; }
	
	public function setData($id, $country, $city, $postal_code, $street, $number, $description)
	{
		$this->id            = $id;
		$this->country       = $country;
		$this->city          = $city;
		$this->postal_code   = $postal_code;
		$this->street        = $street;
		$this->number        = $number;
		$this->description   = $description;
	}
	
	public function setDataByAddressRecord($record)
	{
		if($record instanceof AddressRecord)
		{
			$this->setData(	$record->getId(), $record->getCountry(), $record->getCity(),
							$record->getPostalCode(), $record->getStreet(), $record->getNumber(),
							$record->getDescription());
		}
	}
	
	public function equals($record)
	{
		if($record instanceof AddressRecord)
		{
			return	$this->getCountry() == $record->getCountry()		&&
					$this->getCity() == $record->getCity()				&&
					$this->getPostalCode() == $record->getPostalCode()	&&
					$this->getStreet() == $record->getStreet()			&&
					$this->getNumber() == $record->getNumber() 			&&
					$this->getDescription() == $record->getDescription();
		}
		return false;
	}
	
	public static function finder($className=__CLASS__)
	{
		return parent::finder($className);
	}
}

?>